package com.lehe.controller.admin;

import com.lehe.common.utils.StringUtil;
import com.lehe.entry.GameKindDayOnlineDto;
import com.lehe.entry.SqlParameterDto;
import com.lehe.entry.UserRoomCardResumeDto;
import com.lehe.service.impl.AdminGameReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;
import java.util.List;

/**
 * 类的相关描述
 *
 * @author 王丹
 * @since 2018-01-29
 */
@RequestMapping("admin/gameReport")
@Controller
public class AdminGameReportController extends BaseAdminController {

    @Autowired
    private AdminGameReportService adminGameReportService;

    @RequestMapping("online")
    public String queryGameKindDayOnline(Model model, String endDate){
        Long adminUserId = super.getAdminUserId();
        if(adminUserId!=84 && super.getAdminUserRoleId()!=1){
            return "admin/gameReport/online";
        }
        LocalDate today = LocalDate.now();
        if(StringUtil.isBlank(endDate)){
            endDate = today.toString();
        }
        List<GameKindDayOnlineDto> data = adminGameReportService.queryGameKindDayOnline(endDate);
        model.addAttribute("endDate", endDate);
        model.addAttribute("data", data);
        return "admin/gameReport/online";
    }

    @RequestMapping("roomCard")
    public String queryUserRoomCardResume(Model model, String endDate){
        Long adminUserId = super.getAdminUserId();
        if(adminUserId!=84 && super.getAdminUserRoleId()!=1){
            return "admin/gameReport/roomCard";
        }
        LocalDate today = LocalDate.now();
        if(StringUtil.isBlank(endDate)){
            endDate = today.toString();
        }
        if(super.getAdminUserRoleId()==1){
            adminUserId = 84L;
        }
        List<UserRoomCardResumeDto> data = adminGameReportService.queryUserRoomCardResume(endDate, adminUserId);
        model.addAttribute("endDate", endDate);
        model.addAttribute("data", data);
        return "admin/gameReport/roomCard";
    }

}
